var ScrambledEggs;
(function (ScrambledEggs) {
    (function (Modules) {
        var EndGame = (function () {
            function EndGame() {
                this._endbox = $("#endbox").remove();
            }
            EndGame.prototype.initialize = function (gameState, onUpdate) {
                var $doc = $(document);
                $doc.on("click", "button.getnotified", function () {
                    var button = this;
                    var email = $(".notifyEmail").val();
                    $.ajax({
                        url: "/Api/Notifications",
                        method: "PUT",
                        data: {
                            SaveKey: gameState.Key,
                            Email: email
                        }
                    }).done(function () {
                        $("<p><strong><br />Thank you!<br />&nbsp;</strong></p>").insertAfter($(button).parent());
                        $(button).parent().remove();
                    });
                });
                $doc.on("click", "button.startanew", function () {
                    window.location.href = "/";
                });
            };
            EndGame.prototype.update = function (gameState, triggerSource) {
                var me = this;
                var endGameReached = gameState.State.PartTimeJob != ScrambledEggs.PartTimeJob.None && gameState.State.PartTimeJob != ScrambledEggs.PartTimeJob.Shoemaker && !gameState.Settings.IgnoreEarlyEnding;
                if(endGameReached) {
                    $("button.save").first().click();
                    ScrambledEggs.Utility.General.OptionBox(me._endbox.html());
                }
            };
            return EndGame;
        })();
        Modules.EndGame = EndGame;        
    })(ScrambledEggs.Modules || (ScrambledEggs.Modules = {}));
    var Modules = ScrambledEggs.Modules;
})(ScrambledEggs || (ScrambledEggs = {}));
